<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img {
            width: 300px;
        }
    </style>
</head>

<body>
    <img src="../../../img/图片/cs (1).webp" alt="">
    <div>上午好</div>
    <!-- 根据不同时间段显示不同图片 -->
    <script>
        // 1.获取元素
        var img = document.querySelector('img');
        var div = document.querySelector('div');
        // 2.获取当前小时数
        var date = new Date();
        var h = date.getHours();
        // 3.判断小时数改变图片和文字信息
        if (h < 12) {
            img.src = '../../../img/图片/cs (1).webp';
            div.innerHTML = '上午好!';
        } else if (h < 18) {
            img.src = '../../../img/图片/cs (2).webp';
            div.innerHTML = '下午好!';
        } else {
            img.src = '../../../img/图片/cs (3).webp';
            div.innerHTML = '晚上好!';
        }
    </script>
</body>

</html>